#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	vector<int> v;
	int num =11;
	while(num > 10)
	{ 
		num=1;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]!='0')
			{
				num*= (s[i]-'0');
			}
		}
		v.push_back(num);
		s.resize(0);
		s=to_string(num);
	}
	for(auto e:v)
	{
		cout << e<< endl;
	}
	return 0;
}
